import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";
/**
 * 成績归档-查询
 */
export function selectGdScoreSeting(projId) {
    return fetch({
        url: '/api/scoremanagementservice/scoreDoc/selectGdScoreSeting?projId=' + projId,
        headers: { 'Content-Type': 'application/json' },
        method: 'get'
    });
}

/**
 * 成績归档-新增
 */
export function insertGdScoreSeting(data) {
    return fetch({
        url: '/api/scoremanagementservice/scoreDoc/insertGdScoreSeting',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    });
}

/**
 * 成績归档-更新 
 */
export function updateGdScoreSeting(data) {
    return fetch({
        url: '/api/scoremanagementservice/scoreDoc/updateGdScoreSeting',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    });
}

// 成績归档-查询成绩归档提交列表/审核列表(培养计划已完成的学生)
export function selectGdScoreSubmits(data = {}) {
    return fetch({
        url: '/api/scoremanagementservice/scoreDoc/selectGdScoreSubmits',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    })
}

/**
 * 成績归档-提交/撤回
 */
export function selectGdScoreSubmit(id, applyStatus, grade) {
    return fetch({
        url: `/api/scoremanagementservice/scoreDoc/selectGdScoreSubmit?id=${id}&applyStatus=${applyStatus}&grade=${grade}`,
        headers: { 'Content-Type': 'application/json' },
        method: 'get'
    });
}

/** 
 * 成績归档-批量提交/批量撤回
 */
export function selectGdScoreSubmitAll(applyStatus, data, grade) {
    return fetch({
        url: `/api/scoremanagementservice/scoreDoc/selectGdScoreSubmitAll?applyStatus=${applyStatus}&grade=${grade}`,
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    });
}

/**
 * 成績归档-归档
 */
export function selectGdScoreSubmitArchive(data) {
    return fetch({
        url: '/api/scoremanagementservice/scoreDoc/selectGdScoreSubmitArchive',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    });
}

/**
 * 成績归档-批量归档
 */
export function selectGdScoreSubmitArchiveAll(applyStatus, data) {
    return fetch({
        url: '/api/scoremanagementservice/scoreDoc/selectGdScoreSubmitArchiveAll?applyStatus='+applyStatus,
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    });
}

/**
 * 成績归档-导出
 */
// export function exportScoreDoc(data) {
//     return fetch({
//         url: '/api/scoremanagementservice/scoreDoc/exportScoreDoc?language=cn',
//         method: 'post',
//         headers: { 'Content-Type': 'application/json' },
//         data
//     });
// }
export function exportScoreDoc(data) {
    return fetch({
        url: '/api/scoremanagementservice/scoreDoc/exportScoreDoc?language=cn',
        method: 'post',
        responseType: 'blob',
        data
    }).then(res => {
        UTILS.downloadFile(res, '研究生成绩归档.xlsx', 'application/vnd.ms-excel;charset=utf-8');
    })
}

export default {
    selectGdScoreSeting, insertGdScoreSeting, updateGdScoreSeting,
    selectGdScoreSubmits, selectGdScoreSubmit, selectGdScoreSubmitAll,
    selectGdScoreSubmitArchive, selectGdScoreSubmitArchiveAll, exportScoreDoc
}



